<%@ taglib prefix="c" uri="/WEB-INF/tlds/hdiv-c.tld"%>
<%@ taglib prefix="form" uri="/WEB-INF/tlds/hdiv-spring-form-3_0_4.tld"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>
<c:url value="seleccionarMatriz.html" var="seleccionarMatriz"/>
<jsp:scriptlet>
        org.displaytag.decorator.CheckboxTableDecorator decorator = new org.displaytag.decorator.CheckboxTableDecorator();
        decorator.setId("codMat");
        decorator.setFieldName("_chk");
        pageContext.setAttribute("checkboxDecorator", decorator);
  </jsp:scriptlet>
  <script type="text/javascript">
    $(document).ready(function(){
        $("#codSucuHtb").change(function(){ $("form").submit(); });
        $("#mostrar").click(function(){ $("form").submit(); });
        $("#chkTodos").click(function(){ var checked_status = this.checked;$("input[name='_chk']").each(function(){this.checked = checked_status;}); });
        $("input[name=_chk]").click(function(){ if ($(":checkbox[name=_chk]:not(:checked)").length) $("#chkTodos").attr("checked", false); else $("#chkTodos").attr("checked", true);  });
        $("#aceptar").click(function(){            
            $("#accion").attr("value","seleccionarMatrices");            
            $("form").submit();
            self.close();
            $("#accion",window.opener.document).attr("value","seleccionarMatrices");
            $("form",window.opener.document).submit();
        });
        if (!$(':checkbox[name=_chk]:not(:checked)').length)
            $("#chkTodos").attr('checked', true);
    });
    function updateOpener(){
        $('input[name=accion]', window.opener.document).val("cargarFecha");
        $('#testDiv', window.opener.document).html("Correcto");
      }
  </script>
<form:form modelAttribute="form" name="form" action="${seleccionarMatriz}">
<form:hidden path="accion"/>
<form:hidden path="cliente"/>
    <table id="fullheighttable" width="775" align="center">
        <tr>
            <td align="left" valign="top" class="fondo_contenido padtop16left21">
                <table>
                    <tr>
                        <td class="verdana11bazul">Sucursal</td>
                        <td>
                            <form:select path="codSucuHtb">
                                <form:option value="0">TODOS</form:option>                                
                                      <form:options items="${listSucursales}"
                                                    itemValue="codSucursal"
                                                    itemLabel="desSucursal"/>                                
                            </form:select>
                        </td>
                        <td></td>
                    </tr>
                    <tr>
                        <td class="verdana11bazul">Matriz</td>
                        <td>
                            <form:input path="desMat" cssClass="fondo_txtbox258"/>
                        </td>
                        <td>
                            <input type="button" class="boton" id="mostrar" value="Mostrar"/>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="3" style="color:red;font-weight:bold;text-align:left;">
                        Lista de Matrices
                        </td>
                    </tr>
                    <tr>
                        <td colspan="3">
                        <display:table name="sessionScope.listMatrices" class="its"
                                       pagesize="5" id="matriz" decorator="checkboxDecorator"
                                       form="form" excludedParams="*">
                            <display:column property="checkbox" title="<input type='checkbox' id='chkTodos'/>">                                
                            </display:column>
                            <display:column style="width:400px;text-align:left;" property="desMat" title="<font style='text-align:left;'>Descripcion</font>"/>
                            <display:column style="width:150px;text-align:center;" property="desSucursal" title="Sucursal"/>
                        </display:table>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="3" align="center">                
                            <input type="button" value="Aceptar" id="aceptar" class="boton"/>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr><td></td></tr>
    </table>
</form:form>